package Demo01;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28463
 * Date: 2022—05—14
 * Time: 21:12
 */
class Animal{
    public String name;
    public int age;

    static {
        System.out.println("Animal的静态代码块！");
    }

    {
        System.out.println("Animal的实例代码块！");

    }

    public Animal() {
        System.out.println("Animal不带参数的构造方法！");
    }

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println(name+"正在吃饭！");
    }
}
class Dog extends Animal {
    public float weight;

    static {
        System.out.println("Dog的静态代码块！");
    }

    {
        System.out.println("Dog的实例代码块！");

    }
    public Dog() {
        System.out.println("Dog的不带参数的构造方法！");
    }
    public Dog(String name, int age, float weight) {
        super(name, age);
        this.weight = weight;
    }

    public void bark() {
        System.out.println(name+"正在狗叫");
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", weight=" + weight +
                '}';
    }
}
class cat extends Animal{

    public cat(String name, int age) {
        super(name, age);
    }

    public void bark() {
        System.out.println(name+"正在猫叫");
    }
}
public class Test01 {
    public static void main(String[] args) {
        Dog dog = new Dog();
        System.out.println("====================");
        Dog dog1= new Dog();
    }

/*    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.name = "旺财";
        dog.age = 10;
        dog.weight = 23;
        dog.eat();
        dog.bark();
        System.out.println(dog);
    }*/
}
